﻿using System;
using System.Collections.Generic;
using System.Linq;
using Crosland.Automotriz.Entidad;
using Crosland.Automotriz;

namespace Crosland.Automotriz.Data.Dao.Linq
{
    public class clsTD_SectorDAO
    {
        private DM_CROSLAND_20130417Entities ContextoDeObjs = new DM_CROSLAND_20130417Entities();

        public List<TD_SECTOR> Listar()
        {
            List<TD_SECTOR> lista = new List<TD_SECTOR>();
            try
            {
                var q = from c in ContextoDeObjs.TD_SECTOR
                        orderby c.DES_SECTOR ascending
                        select c;
                lista = q.ToList();
            }
            catch (Exception)
            {

            }
            return lista;
        }
        private Core.AutomotrizEntities ContextodeObjs2 = new Core.AutomotrizEntities();

        public List<Core.TD_SECTOR> Listar2()
        {
            List<Core.TD_SECTOR> lista = new List<Core.TD_SECTOR>();

            var q = from c in ContextodeObjs2.TD_SECTOR
                    orderby c.DES_SECTOR ascending
                    select c;
            lista = q.ToList();


            return lista;
        }

        public String Cod_Sector(int intIdSector)
        {
            String Cod_Sector;
            try
            {
                var q = from c in ContextodeObjs2.TD_SECTOR
                        where c.ID_SECTOR == intIdSector
                        select c;
                Cod_Sector = q.ToList()[0].COD_SECTOR;
            }
            catch (Exception)
            {
                Cod_Sector = "";
            }
            return Cod_Sector;
        }
    }
}
